package com.jams.goodox.entity;

import com.jams.goodox.net.BaseEntity;
import com.jams.goodox.utils.UserUtils;

/**
 * Created by jams_zhen on 2017/6/13.
 */

public class SellerBillResp extends BaseEntity{
    private Data data;

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    public static class Data{
        private String invoiceRule;
        private String invoiceTarget;

        public String getInvoiceRule() {
            return invoiceRule;
        }

        public void setInvoiceRule(String invoiceRule) {
            this.invoiceRule = invoiceRule;
        }

        public String getInvoiceTarget() {
            return invoiceTarget;
        }

        public void setInvoiceTarget(String invoiceTarget) {
            this.invoiceTarget = invoiceTarget;
        }

        //开票对象 1所有用户 2面向企业 3面向员工
        public boolean hasBill(){
            if("0".equalsIgnoreCase(invoiceRule))return false;
            if("2".equalsIgnoreCase(invoiceTarget)&&!UserUtils.isVerifier())return false;//面向授权后的公司员工&&用户未获得授权
            if("3".equalsIgnoreCase(invoiceTarget)&&UserUtils.isUnLinkCompany())return false;//面向员工且未关联企业
            return true;
        }

        /**
         * 不允许开设发票由上设置
         * 允许时，将对应状态放置进入
         * @return 可开设发票类型
         */
        public String getOpenBillType(){
            if(!hasBill())return OrderBillSetBean.BillTypeNull;
            return invoiceRule;
        }
    }
}
